package com.dk.service.impl;

import com.alibaba.fastjson.JSONObject;
import com.dk.mapper.UserMapper;
import com.dk.pojo.User;
import com.dk.pojo.UserExample;
import com.dk.result.Result;
import com.dk.result.ResultConstant;
import com.dk.service.LoginService;
import com.dk.utils.JwtUtil;
import io.jsonwebtoken.Claims;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.server.ServerWebExchange;

import java.util.List;

@Service
public class LoginServiceImpl implements LoginService {

    @Autowired
    private UserMapper userMapper;
    @Autowired
    private JwtUtil jwtUtil;

    @Override
    public User selectByName(String username) {
        UserExample example = new UserExample();
        example.createCriteria().andUsernameEqualTo(username);
        List<User> users = userMapper.selectByExample(example);
        return users.size() > 0 ? users.get(0) : null;
    }

}